// 获取验证码函数
export const getCodeClick = (codeRef) => {
    return new Promise((resolve) => {
        let text = codeRef.value.$el.textContent;
        let sec = 3;  // 60s后重新发送验证码

        let timer = setInterval(() => {
        if ( sec <= 0 ) { // 如果秒数为0时，恢复
            sec = 60;
            clearInterval(timer); // 清除定时器
            resolve(text);
        }
        const secStr = sec-- + '';  // 秒数小于10时在前面添加0
        codeRef.value.$el.textContent = `${secStr.padStart(2, '0')}s`;
        }, 1000);
    })
}